#include<stdio.h>
#include<string.h>
#include<string>
#include <algorithm>
#include<iostream>
using namespace std;
int main()
{
	int n,m, i, begin, end,floor[2000+5];
	while (cin >> n)
	{
		for (i = 0; i <= 2000; i++)floor[i] = 0;
		while (n--)
		{
			cin >> begin >> end;
			for (i = begin; i <= end; i++)floor[i]++;
		}
		cin >> m;
		while (m--)
		{
			cin >> begin >> end;
			for (i = begin; i <= end; i++)printf("%d\r\n", floor[i]);
		}
	}
	return 0;
}